﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace RegexStudy
{
    class Program
    {
        static void Main(string[] args)
        {
            Regex r = new Regex("\\d",RegexOptions.IgnoreCase);
            if (r.IsMatch("800-876"))
            {
                Console.WriteLine("true");
            }
            else
            {
                Console.WriteLine("false");
            }

            string newString= Regex.Replace("qingdao city", @"\b\w{4}\b", Foo);
            Console.WriteLine(newString);

            Console.WriteLine(Regex.IsMatch("March 31, 2006", @"[a-z A-Z][a-z A-Z][a-z A-Z] \d\d.\W\d\d\d\d"));
            Console.WriteLine(Regex.IsMatch("XXX1982 220 988 0009",@"\d\d\d\d \d\d\d \d\d\d \d\d\d\d$"));

            Console.ReadLine();
        }   


        private static string Foo(Match m)
        {
            string matchValue = m.Value;
            Console.WriteLine(matchValue);
            Char[] chas = matchValue.ToCharArray();
            string newString = string.Empty;
            for (int i = chas.Length - 1; i >= 0; i--)
            {
                newString += chas[i].ToString();
            }
            return newString;
        }
    }
}
